package com.anti.modular.sys.role.dao.impl;

import com.anti.jdbc.DBUtils;
import com.anti.modular.sys.role.dao.SysRoleDao;
import com.anti.modular.sys.role.entity.SysRole;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @Description TODO
 * @Author anTi
 * @Date 2021-3-10
 */
@Repository
public class SysRoleDaoImpl implements SysRoleDao {
    @Resource
    DBUtils dbUtils;

    @Override
    public void save(SysRole sysRole) {
        String sql="INSERT INTO sys_role (name, code, sort, remark, status," +
                " create_time, create_user) VALUES (?,?,?,?,?,?,?)";
        dbUtils.execSql(sql,sysRole.getName(),sysRole.getCode(),sysRole.getSort(),sysRole.getRemark(),sysRole.getStatus(),
                sysRole.getCreateTime(),sysRole.getCreateUser());
    }

    @Override
    public void edit(SysRole sysRole) {
        String sql="update sys_role set name=?, code=?, sort=?, remark=?,update_time=?, update_user=? where id=?";
        dbUtils.execSql(sql,sysRole.getName(),sysRole.getCode(),sysRole.getSort(),sysRole.getRemark(),
                sysRole.getUpdateTime(),sysRole.getUpdateUser(),sysRole.getId());
    }

    @Override
    public void delete(Long id) {
        String sql="update sys_role set status=2 where id=?";
        dbUtils.execSql(sql,id);

    }
}
